<!DOCTYPE html>
<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="description" content="A fully featured admin theme which can be used to build CRM, CMS, etc.">
    <meta name="author" content="Coderthemes">
	
	<!-- jQuery  -->
    <script type="text/javascript" src="/plugins/jquery/jquery-3.6.0.min.js"></script>
	
	<!-- layui  -->
	<link rel="stylesheet" href="/plugins/layui/2.7.6/css/layui.css" media="all" />
	<script src="/plugins/layui/2.7.6/layui.js" charset="utf-8"></script>
	
	<!-- 基于laiui的表格 -->
	<script type="text/javascript" src="/plugins/layui/extends/sku/simple_table_choiceshop_price.js"></script>
	
	<!-- 基于laiui的表格 -->
	<script type="text/javascript" src="/plugins/layui/extends/sku/simple_table_choiceshop_detail.js"></script>
	
	
	<!-- 1.0相关引入 -->
	<script src="/dhecp/js/dh-common.js?v=54"></script>
	<script src="/dhecp/js/dh-ui.js?v=36"></script>
	<style>
	/* form表单 */
	.layuiadmin-card-header-auto{background: #fff;box-shadow: 0px 1px 2px 0px rgba(0,0,0,0.1);}
	.layui-form-label{
		width:160px;
		padding: 6px 0px;
		margin: 0px 0px 0px -10px;
	}
	.layui-input-block{
		margin-left: 150px;
    	min-height: 30px;
	}
	.layui-input{height: 28px;}
	.margin_t0{
		margin-top: 0 !important;
	}
	.margin_r0{
		margin-right: 0 !important;
	}
	</style>
</head>
<body>
	<form class="layui-form" id="formId" method="post" action="/hr/choiceshop/addDetail">
		<input type="hidden" name="pcode" th:value="${dto.pcode}">
		<div class="layui-form-item layui-col-xs10">
			<label class="layui-form-label"><font style="color: red;">*</font>商品编码：</label>
			<div class="layui-input-block">            
				<input type="text" id="code" name="code" autocomplete="off" placeholder="请输入商品编码" class="layui-input" lay-verify="required">
			</div>
		</div>
		<div class="layui-form-item layui-col-xs10">
			<label class="layui-form-label"><font style="color: red;">*</font>所在仓库：</label>
			<div class="layui-input-block">            
				<select name="wareHouse" id="wareHouse">
					<option value="福州仓">福州仓</option>
					<option value="英国仓">英国仓</option>
					<option value="美国仓">美国仓</option>
				</select>
			</div>
		</div>
		<div class="layui-form-item layui-col-xs10">
			<label class="layui-form-label"><font style="color: red;">*</font>箱规尺寸(cm)：</label>
			<div class="layui-input-block">            
				<input type="text" id="size" name="size" autocomplete="off" placeholder="点此选择箱规" class="layui-input" lay-verify="required" readonly="readonly" onclick="selectGuageMaintenance()">
			</div>
		</div>
		<div class="layui-form-item layui-col-xs10">
			<label class="layui-form-label"><font style="color: red;">*</font>箱规重量(kg)：</label>
			<div class="layui-input-block">            
				<input type="text" id="weight" name="weight" autocomplete="off" placeholder="" class="layui-input" lay-verify="required" readonly="readonly">
			</div>
		</div>

		<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;"></fieldset>
		<div class="layui-form-item">
			<div class="layui-col-md6 layui-col-md-offset1">
				<div class="layui-btn-container">
					<button type="button" class="layui-btn" lay-submit lay-filter="formSubmit">确定添加</button>
				</div>
			</div>
		</div>
	</form>
	<script th:inline="javascript">
	var gridColumns= [[${gridColumns}]];
	$(function () {
		layui.use(['element', 'form'], function(){
			var element = layui.element,
				form = layui.form;
			
			// 表单提交，共用同一个
			form.on('submit(formSubmit)', function(data){
				var indexOfLoading = layer.load(1, {
					shade: [0.5,'#000000'] //0.1透明度的白色背景
				});
				$.post(data.form.action, data.field, function(res){
					if (res.code == 0) {
						layer.msg(res.msg);
						setTimeout(function(){
							layer.close(indexOfLoading);
							
							var index = parent.layer.getFrameIndex(window.name);
							window.parent.layer.close(index);
							window.parent.tableOfChoiceshopDetail.reloadData();
						}, 1000);
					} else {
						layer.close(indexOfLoading);
						layer.msg(res.msg);
					}
				});
				return false;
			});
		});
	});
	
	function selectGuageMaintenance() {
    	
    	var domForm = $('#formId');
    	var code = domForm.find('#code').val();
    	console.log('code---', code);
    	if(code == null || code == undefined || code == '') {
    		layer.msg('请先输入商品编码');
    		return;
    	}
    	
    	var wareHouse = domForm.find('#wareHouse').val();
    	if(wareHouse == null || wareHouse == undefined || wareHouse == '') {
    		layer.msg('请选择仓库');
    		return;
    	}
		
	    layer.open({
	        type: 2,
	        area: [($(window).width() - 200) + 'px', ($(window).height() - 100) + 'px'],
	        fix: false,//不固定
	        offset: '10%',//距离顶部
	        maxmin: true,//最大最小化
	        shade: 0.3,//遮罩
	        title: '箱规维护列表',
	        content: '/storage/gaugeMaintenance/select?code=' + code + '&warehouseAddress=' + wareHouse,
	        btn: ['确定', '取消'],
	        shadeClose: true,// 弹层外区域关闭
	        yes: function (index, layero) {
	            var res = window["layui-layer-iframe" + index].callbackdata();
	        	var code = domForm.find('#size').val(res.length + '*' + res.width + '*' + res.height);
	        	var code = domForm.find('#weight').val(res.weight);
	            layer.close(index);
	        }
	    });
	}
	</script>

</body>
</html>
